<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="/pages/system/base.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>科研工作量录入</title>
</head>
<body>
	<div
		style="width: 500px; height: 300px; margin: 0px auto; margin-top: 150px">
		<form method="post" id="fm">
			<table cellpadding="5">
				<tr>
					<td><input type="hidden" id="id" name="id" /></td>
				</tr>
				<tr>
					<td>教师:</td>
					<td><input type="hidden" name="teacherid" id="teacherid"></input>
						<input class="easyui-textbox" readonly="readonly" required="true"
						type="text" name="realname" id="realname"></input> <a href="#"
						class="easyui-linkbutton" iconCls="icon-search"
						onclick="openWin('teacherdg','教师信息');">选择</a> <a href="#"
						class="easyui-linkbutton" iconCls="icon-redo"
						onclick="clearText('teacherid','realname');">清空</a></td>
				</tr>
				<tr>
					<td>科研名称:</td>
					<td><input class="easyui-textbox" id="swname" type="text"
						name="swname" maxlength="200" required="true"
						missingMessage="必须填写" style="width: 350px; height: 25px;"></input></td>
				</tr>
				<tr>
					<td>科研类型:</td>
					<td><input type="hidden" name="swtypeid" id="swtypeid"></input>
						<input class="easyui-textbox" readonly="readonly" required="true"
						type="text" name="swtype" id="swtype"></input> <a href="#"
						class="easyui-linkbutton" iconCls="icon-search"
						onclick="openswtypeWin('swtypedg','科研类型信息');">选择</a> <a href="#"
						class="easyui-linkbutton" iconCls="icon-redo"
						onclick="clearText('swtypeid','swtype');">清空</a></td>
				</tr>
				<tr>
					<td>权重类型:</td>
					<td><input type="hidden" name="swweightid" id="swweightid"></input>
						<input class="easyui-textbox" readonly="readonly" required="true"
						type="text" name="swweight" id="swweight"></input> <a href="#"
						class="easyui-linkbutton" iconCls="icon-search"
						onclick="openswweightWin('swweightdg','科研权重信息');">选择</a> <a href="#"
						class="easyui-linkbutton" iconCls="icon-redo"
						onclick="clearText('swweightid','swweight');">清空</a></td>
				</tr>
			</table>
			<div id="dlg-buttons">
				<a href="#" class="easyui-linkbutton  save" onclick="save()"
					iconCls="icon-ok">保存</a> <a href="#"
					class="easyui-linkbutton cancel"
					onclick="javascript:$('#dlg').dialog('close')"
					iconCls="icon-cancel">取消</a>
			</div>
		</form>
	</div>

	<div id="teacherdg" class="easyui-dialog" title="数据"
		style="width: 350px; height: 450px; top: 80px;"
		data-options="modal:true" closed="true" buttons="#dlgTeacher-buttons">
		<table id="teachertable" class="" title="列表"
			style="width: 700px; height: 300px">
			<thead>
				<tr>
					<th data-options="field:'id',width:80">编号</th>
					<th data-options="field:'gonghao',width:80">工号</th>
					<th data-options="field:'realname',width:80">教师姓名</th>
				</tr>
			</thead>
		</table>
	</div>
	<div id="teachertoolbar" style="display: none">
		<div>
			教师姓名: <input class="easyui-textbox" id="paramTeacherName"> <br />
			<a href="#" class="easyui-linkbutton" onclick="teacherSearch()"
				iconCls="icon-search">查找</a> <a href="#" class="easyui-linkbutton"
				onclick="teacherReset()" iconCls="icon-redo">重置</a>
		</div>
	</div>
	<div id="dlgTeacher-buttons">
		<a href="#" class="easyui-linkbutton  save"
			onclick="afterSelect('teachertable','teacherdg','teacherid','realname')"
			iconCls="icon-ok">确定</a> <a href="#" class="easyui-linkbutton cancel"
			onclick="javascript:$('#teacherdg').dialog('close')"
			iconCls="icon-cancel">取消</a>
	</div>

	<!-- d
科研工作量类型
 -->


	<div id="swtypedg" class="easyui-dialog" title="数据"
		style="width: 350px; height: 450px; top: 80px;"
		data-options="modal:true" closed="true" buttons="#dlgswtype-buttons">
		<table id="swtypetable" class="" title="列表"
			style="width: 700px; height: 300px">
			<thead>
				<tr>
					<th data-options="field:'id',width:80">编号</th>
					<th data-options="field:'swtype',width:80">工作量类型</th>
				</tr>
			</thead>
		</table>
	</div>
	<div id="swtypetoolbar" style="display: none">
		<div>
			科研类型: <input class="easyui-textbox" id="paramswtypeName"> <br />
			<a href="#" class="easyui-linkbutton" onclick="swtypeSearch()"
				iconCls="icon-search">查找</a> <a href="#" class="easyui-linkbutton"
				onclick="swtypeReset()" iconCls="icon-redo">重置</a>
		</div>
	</div>
	<div id="dlgswtype-buttons">
		<a href="#" class="easyui-linkbutton  save"
			onclick="afterSwtypeSelect('swtypetable','swtypedg','swtypeid','swtype')"
			iconCls="icon-ok">确定</a> <a href="#" class="easyui-linkbutton cancel"
			onclick="javascript:$('#swtypedg').dialog('close')"
			iconCls="icon-cancel">取消</a>
	</div>


	<!-- d
科研权重类型
 -->


	<div id="swweightdg" class="easyui-dialog" title="数据"
		style="width: 350px; height: 450px; top: 80px;"
		data-options="modal:true" closed="true" buttons="#dlgswweight-buttons">
		<table id="swweighttable" class="" title="列表"
			style="width: 700px; height: 300px">
			<thead>
				<tr>
					<th data-options="field:'id',width:80">编号</th>
					<th data-options="field:'swweight',width:80">工作量权重</th>
				</tr>
			</thead>
		</table>
	</div>
	<div id="swweighttoolbar" style="display: none">
		<div>
			科研权重: <input class="easyui-textbox" id="paramswweightName"> <br />
			<a href="#" class="easyui-linkbutton" onclick="swweightSearch()"
				iconCls="icon-search">查找</a> <a href="#" class="easyui-linkbutton"
				onclick="swweightReset()" iconCls="icon-redo">重置</a>
		</div>
	</div>
	<div id="dlgswweight-buttons">
		<a href="#" class="easyui-linkbutton  save"
			onclick="afterSwweightSelect('swweighttable','swweightdg','swweightid','swweight')"
			iconCls="icon-ok">确定</a> <a href="#" class="easyui-linkbutton cancel"
			onclick="javascript:$('#swweightdg').dialog('close')"
			iconCls="icon-cancel">取消</a>
	</div>


	<script type="text/javascript">
		function afterSwweightSelect(targetDg, targetDlg, valueId, valueName) {
			var row = $("#" + targetDg).datagrid('getSelections');
			if (row.length >= 1) {
				var ids;
				var names;
				for (var i = 0; i < row.length; i++) {
					if (ids == null) {
						ids = row[i].id;
					} else {
						ids = ids + "," + row[i].id;
					}
					if (names == null) {
						names = row[i].swweight;
					} else {
						names = names + "," + row[i].swweight;
					}
					break;
				}
				$("#" + valueId).val(ids);
				$("#" + valueName).textbox('setValue', names);
				$("#" + targetDlg).dialog('close');
			} else {
				$.messager.show({
					title : '提示信息',
					msg : '您未选择任何数据！'
				});
			}
		}

		function afterSwtypeSelect(targetDg, targetDlg, valueId, valueName) {
			var row = $("#" + targetDg).datagrid('getSelections');
			if (row.length >= 1) {
				var ids;
				var names;
				for (var i = 0; i < row.length; i++) {
					if (ids == null) {
						ids = row[i].id;
					} else {
						ids = ids + "," + row[i].id;
					}
					if (names == null) {
						names = row[i].swtype;
					} else {
						names = names + "," + row[i].swtype;
					}
					break;
				}
				$("#" + valueId).val(ids);
				$("#" + valueName).textbox('setValue', names);
				$("#" + targetDlg).dialog('close');
			} else {
				$.messager.show({
					title : '提示信息',
					msg : '您未选择任何数据！'
				});
			}
		}

		function afterSelect(targetDg, targetDlg, valueId, valueName) {
			var row = $("#" + targetDg).datagrid('getSelections');
			if (row.length >= 1) {
				var ids;
				var names;
				for (var i = 0; i < row.length; i++) {
					if (ids == null) {
						ids = row[i].id;
					} else {
						ids = ids + "," + row[i].id;
					}
					if (names == null) {
						names = row[i].realname;
					} else {
						names = names + "," + row[i].realname;
					}
					break;
				}
				$("#" + valueId).val(ids);
				$("#" + valueName).textbox('setValue', names);
				$("#" + targetDlg).dialog('close');
			} else {
				$.messager.show({
					title : '提示信息',
					msg : '您未选择任何数据！'
				});
			}
		}

		function loadSwtypeGrid(queryConditon) {
			$('#swtypetable').datagrid({
				title : '科研类型',
				iconCls : 'icon-ok',
				pageSize : 10,
				pageList : [ 10, 15, 20 ],
				nowrap : true,
				striped : true,
				collapsible : true,
				toolbar : "#swtypetoolbar",
				url : 'scienceWorkTypeController.do?datagrid',
				loadMsg : '数据装载中......',
				singleSelect : false,
				fitColumns : true,
				checkOnSelect : true,
				selectOnCheck : true,
				fit : true,
				remoteSort : false,
				pagination : true,
				rownumbers : true,
				queryParams : queryConditon
			});
		}

		function loadTeacherGrid(queryConditon) {
			$('#teachertable').datagrid({
				title : '教师信息',
				iconCls : 'icon-ok',
				pageSize : 5,
				pageList : [ 5, 10, 15, 20 ],
				nowrap : true,
				striped : true,
				collapsible : true,
				toolbar : "#teachertoolbar",
				url : 'teacherController.do?datagrid',
				loadMsg : '数据装载中......',
				singleSelect : true,
				fitColumns : true,
				checkOnSelect : true,
				selectOnCheck : true,
				fit : true,
				remoteSort : false,
				pagination : true,
				rownumbers : true,
				queryParams : queryConditon
			});
		}

		function loadSwweightGrid(queryConditon){
			 $('#swweighttable').datagrid({  
		            title : '科研权重',  
		            iconCls : 'icon-ok',  
		            pageSize : 10,
		            pageList : [ 10, 15, 20 ],
		            nowrap : true,
		            striped : true,
		            collapsible : true,  
		            toolbar:"#swweighttoolbar", 
		            url:'scienceWorkWeightController.do?datagrid',
		            loadMsg : '数据装载中......',  
		            singleSelect:false,
		            fitColumns:true,  
		            checkOnSelect:true,
		            selectOnCheck:true,
		            fit:true,
		            remoteSort : false,  
		            pagination : true,  
		            rownumbers : true,
		            queryParams:queryConditon
		        });   
		}
		
		function save() {
			$('#fm').form('submit', {
				url : 'scienceWorkController.do?save',
				onSubmit : function() {
					return $(this).form('validate');
				},
				success : function(result) {
					var result = eval('(' + result + ')');
					if (result.success) {
						$.messager.show({
							title : '提示信息',
							msg : result.msg
						});
						clearText('swweightid','swweight');
						clearText('teacherid','realname');
						clearText('swtypeid','swtype');
						clearText('swtypeid','swname');
						
					} else {
						$.messager.show({
							title : '提示信息',
							msg : result.msg
						});
					}
				}
			});
		}

		function teacherSearch() {
			var queryCondition = {
				'realname' : $('#paramTeacherName').val()
			};
			loadTeacherGrid(queryCondition);
		}
		function teacherReset() {
			$('#paramTeacherName').textbox('setValue', '');
			loadTeacherGrid(null);
		}
		function openWin(dgrid, dtittle) {
			$('#' + dgrid).dialog('open').dialog('setTitle', dtittle);
			loadTeacherGrid();
		}

		/*
		工作量方法
		d */

		function swtypeSearch() {
			var queryCondition = {
				'swtype' : $('#paramswtypeName').val()
			};
			loadSwtypeGrid(queryCondition);
		}
		function swtypeReset() {
			$('#paramswtypeName').textbox('setValue', '');
			loadSwtypeGrid(null);
		}
		function openswtypeWin(dgrid, dtittle) {
			$('#' + dgrid).dialog('open').dialog('setTitle', dtittle);
			loadSwtypeGrid();
		}
		
		/*
		权重方法
		d */

		function swweightSearch() {
			var queryCondition = {
				'swweight' : $('#paramswweightName').val()
			};
			loadSwweightGrid(queryCondition);
		}
		function swweightReset() {
			$('#paramswweightName').textbox('setValue', '');
			loadSwweightGrid(null);
		}
		function openswweightWin(dgrid, dtittle) {
			$('#' + dgrid).dialog('open').dialog('setTitle', dtittle);
			loadSwweightGrid();
		}
	</script>

</body>
</html>